<template>
    <div>
        <el-card class="!border-none mt-4" shadow="never">
            <el-table size="large" v-loading="loading" :data="dataList">
                <el-table-column label="数据库id" prop="_id" min-width="100" />
                <el-table-column label="数据库名字" prop="name" min-width="120" />
                <el-table-column label="向量模型" prop="vectorModel.name" min-width="120" />
            </el-table>
        </el-card>
    </div>
</template>

<script>
import axios from 'axios'

export default {
    data() {
        return {
            dataList: [],
            loading: false
        }
    },
    created() {
        this.fetchData()
    },
    methods: {
        async fetchData() {
            try {
                this.loading = true // 开始加载数据时显示 loading
                const authorization =
                    'fastgpt-Z3KJzu4Vy14Rp9xx0R1Hn960G3szeHKJMIZiMcZqQqhnwnv4i1n2o32yedTyzmC3'
                const response = await axios.get('/supergptapi/core/dataset/list?parentId=', {
                    headers: {
                        Authorization: 'Bearer ' + authorization,
                        'Content-Type': 'application/json'
                    }
                })
                this.dataList = response.data.data // 更新 dataList 数据
            } catch (error) {
                console.error('Error fetching data:', error)
            } finally {
                this.loading = false // 数据加载完成后隐藏 loading
            }
        }
    }
}
</script>
